#include <QVBoxLayout>
#include <QWidget>
#include <QtWidgets>
#include <QHBoxLayout>
#include <QPushButton>

int main(int argc,char**argv)
{
    QApplication app(argc,argv);
    QWidget w; //放置空间的窗口
    QSlider* slider=new QSlider(Qt::Horizontal,&w);
    QSpinBox*spinBox=new QSpinBox(&w);
    QPushButton *b1=new QPushButton("aaa",&w);

    
    //QVBoxLayout*layout = new QVBoxLayout(&w);
    QHBoxLayout*layout2 = new QHBoxLayout(&w);
    //layout->addWidget(spinBox);
    //layout->addWidget(slider);

    layout2->addWidget(spinBox);
    layout2->addWidget(slider);
    layout2->addWidget(b1);

    QObject::connect(slider,SIGNAL(valueChanged(int)),spinBox,SLOT(setValue(int)));

    //让窗口使用布局
    //w.setLayout(layout);
    w.setLayout(layout2);
    w.show();

    return app.exec();
}